import pygame
import random
class Food(object):
    def __init__(self,graph,color = (0,0,0)):
        self.graph = graph
        self.size = graph.unit
        self.life=  True
        self.x, self.y = 0,0
        self.position = (self.x, self.y)
        self.color = color
        self.update()

    def update(self):
        self.x = random.randint(0, self.graph.m-1)
        self.y = random.randint(0, self.graph.n-1)
        self.position = (self.x, self.y)

    def display(self, screen):
        pygame.draw.rect(screen, self.color, (self.x * self.size, self.y * self.size, self.size, self.size ), 0)
